﻿using Newtonsoft.Json;
using ReusableJqueryDataTables.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ReusableJqueryDataTables.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            GridResultModel model = new GridResultModel();
            var data = GetSampleData();
            model.Header = new List<string> { "Name", "Position", "Office", "Age", "StartDate", "Salary"};
            model.TableId = "user";
            model.JsonData = JsonConvert.SerializeObject(data);
            return View("Index",model);
        }

        private List<UsersModel> GetSampleData()
        {
            List<UsersModel> userList = new List<UsersModel>();
            UsersModel uModel = new UsersModel();
            uModel.Name = "Airi Satou";
            uModel.Position = "Accountant";
            uModel.Office = "Tokyo";
            uModel.Age = "33";
            uModel.StartDate = "2008/11/28";
            uModel.Salary = "$162,700";
           

            UsersModel uModel1 = new UsersModel();
            uModel1.Name = "Angelica Ramos";
            uModel1.Position = "Chief Executive Officer (CEO)";
            uModel1.Office = "London";
            uModel1.Age = "47";
            uModel1.StartDate = "2009/10/09";
            uModel1.Salary = "$1,200,000";
            

            UsersModel uModel2 = new UsersModel();
            uModel2.Name = "Ashton Cox";
            uModel2.Position = "Junior Technical Author";
            uModel2.Office = "San Francisco";
            uModel2.Age = "66";
            uModel2.StartDate = "2009/01/12	";
            uModel2.Salary = "$86,000";
           

            for (int i = 0; i < 100; i++)
            {
                userList.Add(uModel);
                userList.Add(uModel1);
                userList.Add(uModel2);
            }
           

            return userList;
        }

      
    }
}
